package mo.leetcode_top;

public class L1893 {

    public boolean isCovered(int[][] ranges, int left, int right) {
        boolean[] flag = new boolean[51];
        for (int i = 0; i < ranges.length; i++) {
            int L = Math.max(ranges[i][0], left);
            int R = Math.min(ranges[i][1], right);
            for (int j = L; j <= R; j++) {
                flag[j] = true;
            }
        }
        for (int i = left; i <= right; i++) {
            if (!flag[i]) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        L1893 test = new L1893();
        System.out.println(test.isCovered(new int[][]{{2,2}, {3, 3}, {1, 1}}, 1, 3));
    }

}
